import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { BookingCheckinMasterApi } from '#/api/spa/booking/checkinmaster';

import { z } from '#/adapter/form';
import {
    DICT_TYPE,
    getDictOptions,
    getRangePickerDefaultProps,
} from '#/utils';

import {DICT_SPA_TYPE} from "#/utils/dictSpa";
/** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'id',
      component: 'Input',
      dependencies: {
        triggerFields: [''],
        show: () => false,
      },
    },
    {
      fieldName: 'checkinCode',
      label: '签到编码',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入签到编码',
      },
    },
    {
      fieldName: 'checkinType',
      label: '签到类型',
      rules: 'required',
      component: 'Select',
      componentProps: {
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'string'),
        placeholder: '请选择签到类型',
      },
    },
    {
      fieldName: 'bookingOrderId',
      label: '关联预约订单ID',
      component: 'Input',
      componentProps: {
        placeholder: '请输入关联预约订单ID',
      },
    },
    {
      fieldName: 'groupId',
      label: '关联团体ID',
      component: 'Input',
      componentProps: {
        placeholder: '请输入关联团体ID',
      },
    },
    {
      fieldName: 'groupName',
      label: '团体名称',
      component: 'Input',
      componentProps: {
        placeholder: '请输入团体名称',
      },
    },
    {
      fieldName: 'groupType',
      label: '团体类型',
      component: 'Select',
      componentProps: {
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'string'),
        placeholder: '请选择团体类型',
      },
    },
    {
      fieldName: 'groupSize',
      label: '团体总人数',
      component: 'Input',
      componentProps: {
        placeholder: '请输入团体总人数',
      },
    },
    {
      fieldName: 'groupLeaderId',
      label: '团体负责人ID',
      component: 'Input',
      componentProps: {
        placeholder: '请输入团体负责人ID',
      },
    },
    {
      fieldName: 'groupLeaderName',
      label: '团体负责人姓名',
      component: 'Input',
      componentProps: {
        placeholder: '请输入团体负责人姓名',
      },
    },
    {
      fieldName: 'expectedArrivalTime',
      label: '预计到店时间',
      component: 'DatePicker',
      componentProps: {
        showTime: true,
        format: 'YYYY-MM-DD HH:mm:ss',
        valueFormat: 'x',
      },
    },
    {
      fieldName: 'firstArrivalTime',
      label: '首个成员到店时间',
      component: 'DatePicker',
      componentProps: {
        showTime: true,
        format: 'YYYY-MM-DD HH:mm:ss',
        valueFormat: 'x',
      },
    },
    {
      fieldName: 'lastArrivalTime',
      label: '最后成员到店时间',
      component: 'DatePicker',
      componentProps: {
        showTime: true,
        format: 'YYYY-MM-DD HH:mm:ss',
        valueFormat: 'x',
      },
    },
    {
      fieldName: 'lateArrivalTolerance',
      label: '迟到容忍时间(分钟)',
      component: 'Input',
      componentProps: {
        placeholder: '请输入迟到容忍时间(分钟)',
      },
    },
    {
      fieldName: 'checkinStatus',
      label: '签到状态',
      rules: 'required',
      component: 'RadioGroup',
      componentProps: {
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'string'),
        buttonStyle: 'solid',
        optionType: 'button',
      },
    },
    {
      fieldName: 'arrivedCount',
      label: '已到店人数',
      component: 'Input',
      componentProps: {
        placeholder: '请输入已到店人数',
      },
    },
    {
      fieldName: 'totalCount',
      label: '总人数',
      component: 'Input',
      componentProps: {
        placeholder: '请输入总人数',
      },
    },
    {
      fieldName: 'noShowCount',
      label: '未到店人数',
      component: 'Input',
      componentProps: {
        placeholder: '请输入未到店人数',
      },
    },
    {
      fieldName: 'conversionStatus',
      label: '转换状态',
      component: 'RadioGroup',
      componentProps: {
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'string'),
        buttonStyle: 'solid',
        optionType: 'button',
      },
    },
    {
      fieldName: 'conversionTime',
      label: '转换时间',
      component: 'DatePicker',
      componentProps: {
        showTime: true,
        format: 'YYYY-MM-DD HH:mm:ss',
        valueFormat: 'x',
      },
    },
    {
      fieldName: 'conversionUserId',
      label: '转换操作人ID',
      component: 'Input',
      componentProps: {
        placeholder: '请输入转换操作人ID',
      },
    },
    {
      fieldName: 'checkinSource',
      label: '签到来源',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入签到来源',
      },
    },
    {
      fieldName: 'sourceChannel',
      label: '来源渠道',
      component: 'Input',
      componentProps: {
        placeholder: '请输入来源渠道',
      },
    },
    {
      fieldName: 'checkinNotes',
      label: '签到备注',
      component: 'Input',
      componentProps: {
        placeholder: '请输入签到备注',
      },
    },
    {
      fieldName: 'storeId',
      label: '门店ID',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入门店ID',
      },
    },
    {
      fieldName: 'orgId',
      label: '组织ID',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入组织ID',
      },
    },
  ];
}

/** 列表的搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'checkinCode',
      label: '签到编码',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入签到编码',
      },
    },
    {
      fieldName: 'checkinType',
      label: '签到类型',
      component: 'Select',
      componentProps: {
        allowClear: true,
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'string'),
        placeholder: '请选择签到类型',
      },
    },
    {
      fieldName: 'bookingOrderId',
      label: '关联预约订单ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入关联预约订单ID',
      },
    },
    {
      fieldName: 'groupId',
      label: '关联团体ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入关联团体ID',
      },
    },
    {
      fieldName: 'groupName',
      label: '团体名称',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入团体名称',
      },
    },
    {
      fieldName: 'groupType',
      label: '团体类型',
      component: 'Select',
      componentProps: {
        allowClear: true,
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'string'),
        placeholder: '请选择团体类型',
      },
    },
    {
      fieldName: 'groupSize',
      label: '团体总人数',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入团体总人数',
      },
    },
    {
      fieldName: 'groupLeaderId',
      label: '团体负责人ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入团体负责人ID',
      },
    },
    {
      fieldName: 'groupLeaderName',
      label: '团体负责人姓名',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入团体负责人姓名',
      },
    },
    {
      fieldName: 'expectedArrivalTime',
      label: '预计到店时间',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
    {
      fieldName: 'firstArrivalTime',
      label: '首个成员到店时间',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
    {
      fieldName: 'lastArrivalTime',
      label: '最后成员到店时间',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
    {
      fieldName: 'lateArrivalTolerance',
      label: '迟到容忍时间(分钟)',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入迟到容忍时间(分钟)',
      },
    },
    {
      fieldName: 'checkinStatus',
      label: '签到状态',
      component: 'Select',
      componentProps: {
        allowClear: true,
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'string'),
        placeholder: '请选择签到状态',
      },
    },
    {
      fieldName: 'arrivedCount',
      label: '已到店人数',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入已到店人数',
      },
    },
    {
      fieldName: 'totalCount',
      label: '总人数',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入总人数',
      },
    },
    {
      fieldName: 'noShowCount',
      label: '未到店人数',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入未到店人数',
      },
    },
    {
      fieldName: 'conversionStatus',
      label: '转换状态',
      component: 'Select',
      componentProps: {
        allowClear: true,
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'string'),
        placeholder: '请选择转换状态',
      },
    },
    {
      fieldName: 'conversionTime',
      label: '转换时间',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
    {
      fieldName: 'conversionUserId',
      label: '转换操作人ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入转换操作人ID',
      },
    },
    {
      fieldName: 'checkinSource',
      label: '签到来源',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入签到来源',
      },
    },
    {
      fieldName: 'sourceChannel',
      label: '来源渠道',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入来源渠道',
      },
    },
    {
      fieldName: 'checkinNotes',
      label: '签到备注',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入签到备注',
      },
    },
    {
      fieldName: 'storeId',
      label: '门店ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入门店ID',
      },
    },
    {
      fieldName: 'orgId',
      label: '组织ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入组织ID',
      },
    },
    {
      fieldName: 'createTime',
      label: '创建时间',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
  ];
}

/** 列表的字段 */
export function useGridColumns(): VxeTableGridOptions<BookingCheckinMasterApi.BookingCheckinMaster>['columns'] {
  return [
    {
      field: 'id',
      title: '签到主表ID',
      minWidth: 120,

    },
    {
      field: 'checkinCode',
      title: '签到编码',
      minWidth: 120,

    },
    {
      field: 'checkinType',
      title: '签到类型',
      minWidth: 120,

    },
    {
      field: 'bookingOrderId',
      title: '关联预约订单ID',
      minWidth: 120,

    },
    {
      field: 'groupId',
      title: '关联团体ID',
      minWidth: 120,

    },
    {
      field: 'groupName',
      title: '团体名称',
      minWidth: 120,

    },
    {
      field: 'groupType',
      title: '团体类型',
      minWidth: 120,

    },
    {
      field: 'groupSize',
      title: '团体总人数',
      minWidth: 120,

    },
    {
      field: 'groupLeaderId',
      title: '团体负责人ID',
      minWidth: 120,

    },
    {
      field: 'groupLeaderName',
      title: '团体负责人姓名',
      minWidth: 120,

    },
    {
      field: 'expectedArrivalTime',
      title: '预计到店时间',
      minWidth: 120,
      formatter: 'formatDateTime',
    },
    {
      field: 'firstArrivalTime',
      title: '首个成员到店时间',
      minWidth: 120,
      formatter: 'formatDateTime',
    },
    {
      field: 'lastArrivalTime',
      title: '最后成员到店时间',
      minWidth: 120,
      formatter: 'formatDateTime',
    },
    {
      field: 'lateArrivalTolerance',
      title: '迟到容忍时间(分钟)',
      minWidth: 120,

    },
    {
      field: 'checkinStatus',
      title: '签到状态',
      minWidth: 120,

    },
    {
      field: 'arrivedCount',
      title: '已到店人数',
      minWidth: 120,

    },
    {
      field: 'totalCount',
      title: '总人数',
      minWidth: 120,

    },
    {
      field: 'noShowCount',
      title: '未到店人数',
      minWidth: 120,

    },
    {
      field: 'conversionStatus',
      title: '转换状态',
      minWidth: 120,

    },
    {
      field: 'conversionTime',
      title: '转换时间',
      minWidth: 120,
      formatter: 'formatDateTime',
    },
    {
      field: 'conversionUserId',
      title: '转换操作人ID',
      minWidth: 120,

    },
    {
      field: 'checkinSource',
      title: '签到来源',
      minWidth: 120,

    },
    {
      field: 'sourceChannel',
      title: '来源渠道',
      minWidth: 120,

    },
    {
      field: 'checkinNotes',
      title: '签到备注',
      minWidth: 120,

    },
    {
      field: 'storeId',
      title: '门店ID',
      minWidth: 120,

    },
    {
      field: 'orgId',
      title: '组织ID',
      minWidth: 120,

    },
    {
      field: 'createTime',
      title: '创建时间',
      minWidth: 120,
      formatter: 'formatDateTime',
    },
    {
      title: '操作',
      width: 200,
      fixed: 'right',
      slots: { default: 'actions' },
    },
  ];
}

